package com.bistu.openlab.uofspreadsheet.executive;

import java.io.File;

import com.bistu.openlab.uofspreadsheet.model.ExcelDocument;
import com.bistu.openlab.uofspreadsheet.xmlparse.ExcelDocumentParse;

/*
 *@author xiaoguang.gao@oracle.com
 *@version 2013-5-8 
 */
public class ExcelDocumentFactory {
	private static ExcelDocumentFactory factory = new ExcelDocumentFactory();

	private ExcelDocumentFactory(){
		
	}
	/**
	 *  Default excel factory
	 */
	public static ExcelDocumentFactory getDefaultFactory(){
		return factory;
	}
	/**
	 * create a new Excel Document
	 * @return
	 */
	public ExcelDocument createExcelDocument(){
		//initial excel document
		ExcelDocument excelDoc = new ExcelDocument();		
		return excelDoc;
	}
	/**
	 * load a uos file
	 * @param uosFile
	 * @return
	 */
	public ExcelDocument loadExcelDocument(File uosFile){
		ExcelDocumentParse parse = ExcelDocumentParse.getInstance();
		ExcelDocument excelDoc = parse.readFromFile(uosFile);
		return excelDoc;
	}
	/**
	 * save uos file
	 * @param excelDoc
	 * @param targetPath
	 */
	public void saveAs(ExcelDocument excelDoc, String targetPath){
		ExcelDocumentParse parse = ExcelDocumentParse.getInstance();
		parse.writeToFile(excelDoc, new File(targetPath));
	}
}
